export const localStorageUtil = {
  setData(key: string, value: unknown): void {
    localStorage.setItem(key, JSON.stringify(value))
  },
  getData(key: string): unknown {
    const storedStr = localStorage.getItem(key)
    if (storedStr == undefined) {
      return null
    } else if (!storedStr) {
      return null
    } else {
      return JSON.parse(storedStr)
    }
  },
  removeData(key: string): void {
    localStorage.removeItem(key)
  },
  clear(): void {
    localStorage.clear()
  }
}

export const sessionStorageUtil = {
  setData(key: string, value: unknown): void {
    sessionStorage.setItem(key, JSON.stringify(value))
  },
  getData(key: string): unknown {
    const storedStr = sessionStorage.getItem(key)
    if (storedStr == undefined) {
      return null
    } else if (!storedStr) {
      return null
    } else {
      return JSON.parse(storedStr)
    }
  },
  removeData(key: string): void {
    sessionStorage.removeItem(key)
  },
  clear(): void {
    sessionStorage.clear()
  }
}
